<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="google-site-verification" content="xBT4GhYoi5qRD5tr338pgPM5OWHHIDR6mNg1a3euekI" />
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="">
    <meta name="keyword"  content="Tooi">
    <link rel="shortcut icon" href="/img/favicon.ico">

    <title>
        
        【树莓派】系统安装和配置 - Tooi的博客 | Tooi-Blog
        
    </title>

    <!-- Custom CSS -->
    <link rel="stylesheet" href="/css/aircloud.css">
    <link rel="stylesheet" href="/css/gitment.css">
    <!--<link rel="stylesheet" href="https://imsun.github.io/gitment/style/default.css">-->
    <link href="//at.alicdn.com/t/font_620856_pl6z7sid89qkt9.css" rel="stylesheet" type="text/css">
    <!-- ga & ba script hoook -->
    <script></script>
</head>

<body>

<div class="site-nav-toggle" id="site-nav-toggle">
    <button>
        <span class="btn-bar"></span>
        <span class="btn-bar"></span>
        <span class="btn-bar"></span>
    </button>
</div>

<div class="index-about">
    <i> 瞄准月亮。 </i>
</div>

<div class="index-container">
    
    <div class="index-left">
        
<div class="nav" id="nav">
    <div class="avatar-name">
        <div class="avatar ">
            <img src="/img/avatar.jpg" />
        </div>
        <div class="name">
            <i>Tooi6</i>
        </div>
    </div>
    <div class="contents" id="nav-content">
        <ul>
            <li >
                <a href="/">
                    <i class="iconfont icon-shouye1"></i>
                    <span>主页</span>
                </a>
            </li>
            <li >
                <a href="/tags">
                    <i class="iconfont icon-biaoqian1"></i>
                    <span>标签</span>
                </a>
            </li>
            <li >
                <a href="/archives">
                    <i class="iconfont icon-guidang2"></i>
                    <span>存档</span>
                </a>
            </li>
            <li >
                <a href="/about/">
                    <i class="iconfont icon-guanyu2"></i>
                    <span>关于</span>
                </a>
            </li>
            
            <li>
                <a id="search">
                    <i class="iconfont icon-sousuo1"></i>
                    <span>搜索</span>
                </a>
            </li>
            
        </ul>
    </div>
    
        <div id="toc" class="toc-article">
    <ol class="toc"><li class="toc-item toc-level-3"><a class="toc-link" href="#官网"><span class="toc-text">官网</span></a><ol class="toc-child"><li class="toc-item toc-level-4"><a class="toc-link" href="#中文社区"><span class="toc-text">中文社区</span></a></li></ol></li><li class="toc-item toc-level-3"><a class="toc-link" href="#安装系统"><span class="toc-text">安装系统</span></a><ol class="toc-child"><li class="toc-item toc-level-4"><a class="toc-link" href="#下载系统"><span class="toc-text">下载系统</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#写入镜像"><span class="toc-text">写入镜像</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#设置wifi和ssh"><span class="toc-text">设置wifi和ssh</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#使用-ssh-连接树莓派"><span class="toc-text">使用 ssh 连接树莓派</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#更换源"><span class="toc-text">更换源</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#更换-pip-源"><span class="toc-text">更换 pip 源</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#配置树莓派"><span class="toc-text">配置树莓派</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#使用-VNC-连接"><span class="toc-text">使用 VNC 连接</span></a></li></ol></li></ol>
</div>
    
</div>


<div class="search-field" id="search-field">
    <div class="search-container">
        <div class="search-input">
            <span id="esc-search"> <i class="icon-fanhui iconfont"></i></span>
            <input id="search-input"/>
            <span id="begin-search">搜索</span>
        </div>
        <div class="search-result-container" id="search-result-container">

        </div>
    </div>
</div>

        <div class="index-about-mobile">
            <i> 瞄准月亮。 </i>
        </div>
    </div>
    
    <div class="index-middle">
        <!-- Main Content -->
        


<div class="post-container">
    <div class="post-title">
        【树莓派】系统安装和配置
    </div>

    <div class="post-meta">
        <span class="attr">发布于：<span>2019-11-15 14:40:06</span></span>
        
        <span class="attr">标签：/
        
        <a class="tag" href="/tags/#树莓派" title="树莓派">树莓派</a>
        <span>/</span>
        
        
        </span>
        <span class="attr">访问：<span id="busuanzi_value_page_pv"></span>
</span>
</span>
    </div>
    <div class="post-content ">
        <h3 id="官网"><a href="#官网" class="headerlink" title="官网"></a>官网</h3><blockquote>
<p><a href="https://www.raspberrypi.org/" target="_blank" rel="noopener">https://www.raspberrypi.org/</a></p>
</blockquote>
<h4 id="中文社区"><a href="#中文社区" class="headerlink" title="中文社区"></a>中文社区</h4><blockquote>
<p>树莓派实验室：<a href="http://shumeipai.nxez.com/" target="_blank" rel="noopener">http://shumeipai.nxez.com/</a><br>Linux 中国：<a href="https://linux.cn/tech/raspberrypi/" target="_blank" rel="noopener">https://linux.cn/tech/raspberrypi/</a></p>
</blockquote>
<h3 id="安装系统"><a href="#安装系统" class="headerlink" title="安装系统"></a>安装系统</h3><blockquote>
<p>raspbian 历史版本：<a href="http://downloads.raspberrypi.org/raspbian/images/" target="_blank" rel="noopener">http://downloads.raspberrypi.org/raspbian/images/</a>    </p>
</blockquote>
<h4 id="下载系统"><a href="#下载系统" class="headerlink" title="下载系统"></a>下载系统</h4><h4 id="写入镜像"><a href="#写入镜像" class="headerlink" title="写入镜像"></a>写入镜像</h4><blockquote>
<p>使用 Etcher 等工具写入系统镜像</p>
</blockquote>
<h4 id="设置wifi和ssh"><a href="#设置wifi和ssh" class="headerlink" title="设置wifi和ssh"></a>设置wifi和ssh</h4><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br></pre></td><td class="code"><pre><span class="line"># 在boot文件夹下新建 ssh 和 wpa_supplicant.conf 文件  </span><br><span class="line"></span><br><span class="line"># wpa_supplicant.conf 文件：</span><br><span class="line">country=GB</span><br><span class="line">ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev</span><br><span class="line">update_config=1</span><br><span class="line">network=&#123;</span><br><span class="line">        ssid=&quot;Tooi&quot;</span><br><span class="line">        psk=&quot;zx123456&quot;</span><br><span class="line">        priority=1</span><br><span class="line">&#125;</span><br><span class="line">## ssid：wifi名称</span><br><span class="line">## psk：wifi密码</span><br><span class="line">## prioity：优先级（越小优先级越高）</span><br></pre></td></tr></table></figure>

<h4 id="使用-ssh-连接树莓派"><a href="#使用-ssh-连接树莓派" class="headerlink" title="使用 ssh 连接树莓派"></a>使用 ssh 连接树莓派</h4><blockquote>
<p>账号：pi<br>默认密码：raspberry</p>
</blockquote>
<h4 id="更换源"><a href="#更换源" class="headerlink" title="更换源"></a>更换源</h4><blockquote>
<p>查看有哪些源：<a href="https://www.raspbian.org/RaspbianMirrors" target="_blank" rel="noopener">https://www.raspbian.org/RaspbianMirrors</a></p>
</blockquote>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line"># 编辑</span><br><span class="line">sudo nano /etc/apt/sources.list</span><br><span class="line"># 将内容替换成：</span><br><span class="line">deb http://mirrors.tuna.tsinghua.edu.cn/raspbian/raspbian/ stretch main contrib non-free rpi</span><br><span class="line">deb-src http://mirrors.tuna.tsinghua.edu.cn/raspbian/raspbian/ stretch main contrib non-free rpi</span><br><span class="line"></span><br><span class="line"># 更新</span><br><span class="line">sudo apt-get update</span><br></pre></td></tr></table></figure>
<blockquote>
<p>如果使用 wifi 网速慢的话可以试试更换DNS：<br>sudo nano /etc/resolv.conf<br>nameserver 8.8.8.8  </p>
</blockquote>
<h4 id="更换-pip-源"><a href="#更换-pip-源" class="headerlink" title="更换 pip 源"></a>更换 pip 源</h4><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line">sudo mkdir ~/.pip</span><br><span class="line">sudo nano ~/.pip.conf</span><br><span class="line"></span><br><span class="line">[global]</span><br><span class="line">timeout = 10</span><br><span class="line">index-url =  http://mirrors.aliyun.com/pypi/simple/</span><br><span class="line">extra-index-url= http://pypi.douban.com/simple/</span><br><span class="line">[install]</span><br><span class="line">trusted-host=</span><br><span class="line">    mirrors.aliyun.com</span><br><span class="line">    pypi.douban.com</span><br></pre></td></tr></table></figure>

<h4 id="配置树莓派"><a href="#配置树莓派" class="headerlink" title="配置树莓派"></a>配置树莓派</h4><blockquote>
<p>sudo raspi-config  </p>
</blockquote>
<p><img src="https://note.youdao.com/yws/api/personal/file/995813D581F44829A17F483742A7652A?method=download&shareKey=be956a1a46d86d3860497cb11f5c16d0" alt="image"></p>
<ul>
<li><p><strong>Change User Password：</strong>  </p>
<blockquote>
<p>修改当前用户的密码</p>
</blockquote>
</li>
<li><p><strong>Localisation Options</strong> ：</p>
<blockquote>
<p>本地化设置（修改地区，时区，wifi）  </p>
</blockquote>
</li>
<li><p><strong>Interfacing Options</strong></p>
<blockquote>
<p>打开Camera（相机）、SSH、Serial、Remote GPIO</p>
</blockquote>
</li>
<li><p><strong>Advanced Options</strong></p>
<blockquote>
<p>选择<strong>Expand Filesystem</strong>，将根目录扩展到这个SD卡，充分利用SD卡的存储空间<br>选择<strong>Overscan</strong>，在整个屏幕上显示<br>选择<strong>Audio</strong>，选择Force 3.5mm(‘headphone’ jack)，树莓派的声音会从耳机孔输出<br>选择<strong>Resolution</strong>，选择默认设置，自动根据显示屏调整分辨率<br>选择<strong>Pixel Doubling</strong>，增加桌面显示画质  </p>
</blockquote>
</li>
</ul>
<h4 id="使用-VNC-连接"><a href="#使用-VNC-连接" class="headerlink" title="使用 VNC 连接"></a>使用 VNC 连接</h4><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br></pre></td><td class="code"><pre><span class="line"># 进入 Interfacing Options 配置，开启 VNC</span><br><span class="line">sudo raspi-config  </span><br><span class="line"></span><br><span class="line"># 新建配置文件</span><br><span class="line">sudo nano /etc/init.d/vncserver</span><br><span class="line">### begin ###</span><br><span class="line">#!/bin/sh</span><br><span class="line">### BEGIN INIT INFO</span><br><span class="line"># Provides: vncserver</span><br><span class="line"># Required-Start: $local_fs</span><br><span class="line"># Required-Stop: $local_fs</span><br><span class="line"># Default-Start: 2 3 4 5</span><br><span class="line"># Default-Stop: 0 1 6</span><br><span class="line"># Short-Description: Start/stop vncserver</span><br><span class="line">### END INIT INFO</span><br><span class="line"># More details see:</span><br><span class="line"># http://www.penguintutor.com/linux/vnc</span><br><span class="line">### Customize this entry</span><br><span class="line"># Set the USER variable to the name of the user to start vncserver under</span><br><span class="line">export USER=&apos;pi&apos;</span><br><span class="line">### End customization required</span><br><span class="line">eval cd ~$USER</span><br><span class="line">case &quot;$1&quot; in</span><br><span class="line">start)</span><br><span class="line"># 启动命令行。此处自定义分辨率、控制台号码或其它参数。</span><br><span class="line">su $USER -c &apos;/usr/bin/vncserver -depth 16 -geometry 1024x768 :1&apos;</span><br><span class="line">echo &quot;Starting VNC server for $USER &quot;</span><br><span class="line">;;</span><br><span class="line">stop)</span><br><span class="line"># 终止命令行。此处控制台号码与启动一致。</span><br><span class="line">su $USER -c &apos;/usr/bin/vncserver -kill :1&apos;</span><br><span class="line">echo &quot;vncserver stopped&quot;</span><br><span class="line">;;</span><br><span class="line">*)</span><br><span class="line">echo &quot;Usage: /etc/init.d/vncserver &#123;start|stop&#125;&quot;</span><br><span class="line">exit 1</span><br><span class="line">;;</span><br><span class="line">esac</span><br><span class="line">exit 0</span><br><span class="line">### end ###</span><br><span class="line"></span><br><span class="line"># 修改权限</span><br><span class="line">sudo chmod 755 /etc/init.d/vncserver  </span><br><span class="line"></span><br><span class="line"># 开机启动  </span><br><span class="line">sudo update-rc.d vncserver defaults</span><br><span class="line"></span><br><span class="line"># 重启 </span><br><span class="line">sudo reboot</span><br><span class="line"></span><br><span class="line"># 开机后就可以连接了</span><br><span class="line">账户：pi</span><br><span class="line">默认密码：raspberry</span><br></pre></td></tr></table></figure>


        
            <div class="donate-container">
    <div class="donate-button">
        <button id="donate-button">赞赏</button>
    </div>
    <div class="donate-img-container hide" id="donate-img-container">
        <img id="donate-img" src="" data-src="/img/donate.png">
        <p> 感谢鼓励 </p>
    </div>
</div>
        
        <br />
        <div id="comment-container">
        </div>
        <div id="disqus_thread"></div>

        <div id="lv-container">
        </div>

    </div>
</div>

    </div>
</div>


<footer class="footer">
    <ul class="list-inline text-center">
        
        

        

        

        
        <li>
            <a target="_blank"  href="https://github.com/Tooi6">
                            <span class="fa-stack fa-lg">
                                <i class="iconfont icon-github"></i>
                            </span>
            </a>
        </li>
        

        

    </ul>
    
    <p>
        <span>/</span>
        
        <span><a href="https://github.com/Tooi6" target="_blank" rel="noopener">Tooi6</a></span>
        <span>/</span>
        
        <span><a href="#">Tooi-Blog</a></span>
        <span>/</span>
        
        <span><a href="#">It helps SEO</a></span>
        <span>/</span>
        
    </p>
    
    <p>
        <span id="busuanzi_container_site_pv">
            <span id="busuanzi_value_site_pv"></span>PV
        </span>
        <span id="busuanzi_container_site_uv">
            <span id="busuanzi_value_site_uv"></span>UV
        </span>
        Created By <a href="https://hexo.io/" target="_blank" rel="noopener">Hexo</a>  Theme <a href="https://github.com/aircloud/hexo-theme-aircloud" target="_blank" rel="noopener">AirCloud</a></p>
</footer>




</body>

<script>
    // We expose some of the variables needed by the front end
    window.hexo_search_path = "search.json"
    window.hexo_root = "/"
    window.isPost = true
</script>
<script src="https://cdn.bootcss.com/jquery/3.3.1/jquery.min.js"></script>
<script src="/js/index.js"></script>
<script async src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>




</html>
